feat: Add FDv2 wire format and protocol handler#177
Conversation
| pub(super) version: u64, | ||
| pub(super) kind: String, | ||
| pub(super) key: String, | ||
| pub(super) object: serde_json::Value, |
There was a problem hiding this comment.
What do we think about using serde's raw value? Might save some cycles if we find we need to discard part of the stream.
There was a problem hiding this comment.
I prefer keeping this as Value to be consistent with how it's written in C++ and Java. I'm open to discussing it further.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b84b315. Configure here.
|
I decided to move some of the types to a separate module, to better reflect how the other SDKs are structured. |
a81f3b6 to
7c71c55
Compare

Summary
fdv2module:ChangeSet/Selectortypesserde_json::Value; typed deserialization will live in a later translator.Selectorkeeps the deprecatedversionfield alongsidestateGoodbyeandFDv2Erroruse optional fields to tolerate permissively-parsed wire data#[allow(dead_code)]for now: types are covered by unit tests but not yet reachable from the production data path.Note
Low Risk
New code is test-only and not on the live flag data path; behavior changes only when FDv2 is integrated later.
Overview
Adds a new
fdv2module (registered inlib.rsbut#[allow(dead_code)]until the streaming data path uses it) for LaunchDarkly FDv2 streaming.Wire layer (
wire.rs): deserializes SSE payloads—server-intent,put-object/delete-object,payload-transferred,error,goodbye—with permissive parsing (unknown intent codes →Unknown, optional fields onGoodbye/FDv2Error). Put bodies stay asserde_json::Valuefor a later translator.Protocol (
protocol.rs):FDv2ProtocolHandlerfolds events intoChangeSetvalues (None/Full/Partialplus put/delete ops and a selector frompayload-transferred.state). It tracks full vs partial transfer intent, allows further put/delete cycles without a newserver-intentafter the first payload, clears buffered changes on servererrorwhile keeping transfer state, and resets ongoodbye.Unit tests cover wire parsing and protocol edge cases (malformed JSON, unknown events, protocol violations).
Reviewed by Cursor Bugbot for commit 7c71c55. Bugbot is set up for automated code reviews on this repo. Configure here.